package com.woniuxy.table.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.table.client.DiningAreaQueryClient;
import com.woniuxy.table.client.param.LoadAllDiningAreaParam;
import com.woniuxy.table.client.result.DiningAreaClientDto;
import com.woniuxy.table.service.DiningAreaService;
import com.woniuxy.table.service.dto.DiningAreaDto;
import com.woniuxy.table.service.param.LoadAllDiningAreaServiceParam;
import common.WoniuPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

@RestController
public class DiningAreaQueryApiImpl implements DiningAreaQueryClient {
    @Autowired
    private DiningAreaService diningAreaService;
    @Log("查询商家区域")
    @Override
    public Result<WoniuPage<DiningAreaClientDto>> loadAllDiningArea(LoadAllDiningAreaParam loadAllDiningAreaParam) {
        if (loadAllDiningAreaParam.getPageIndex()==null){
            loadAllDiningAreaParam.setPageIndex(1);
        }
        if (loadAllDiningAreaParam.getPageSize()==null){
            loadAllDiningAreaParam.setPageSize(3);
        }
        LoadAllDiningAreaServiceParam loadAllDiningAreaServiceParam = BeanUtil.toBean(loadAllDiningAreaParam, LoadAllDiningAreaServiceParam.class);

        WoniuPage<DiningAreaDto> list = diningAreaService.loadAllDiningArea(loadAllDiningAreaServiceParam);
        return Result.success(list);
    }
}
